﻿<%@ Page Language="C#" AutoEventWireup="false" Inherits="Web.BasePage"%>
<%@ Import Namespace="Web.Controller" %>
<%@ Import Namespace="Web" %>
<%@ Import Namespace="Web.UI" %>
<%@ Import Namespace="MAF.Common" %>
<fieldset>
    <legend>添加</legend>
    <form id="frmAddProduct" method="post" action="Ajax.aspx?Module=<%=this.Module %>&Handler=Product&Action=Add">
    <dl>
        <dt>产品分类：</dt>
        <dd><select name="ParentId"><%=CategoryUI.Options() %></select></dd>
        
        <dt>产品名称：</dt>
        <dd><input type="text" name="Name" /></dd>
        
        <dt>产品图片：</dt>
        <dd>
            <span><input type="file" id="ajaxFile" name="file" /></span>
            <input type="button" id="ajaxButton" value="上传" />
            <input type="hidden" name="FilePath" />
            
            <span style="display:none" class="uploading">上传中...</span>
            <img src="#" style="display:none;width:100px;height:100px;" class="preview" />
        </dd>

        <dt>价格：</dt>
        <dd><input type="text" name="Price" /></dd>

        <dt>适宜群：</dt>
        <dd><input type="text" name="Apply" /></dd>

        <dt>产品描述：</dt>
        <dd><textarea name="Description"></textarea></dd>

        <dt>产品内容：</dt>
        <dd><textarea name="Content" class="ckeditor"></textarea></dd>
        
        <dt>发布日期：</dt>
        <dd><input type="text" name="PublishedDate" value="<%=DateTime.Now.ToString() %>" /></dd>
        
        <dt>热门产品：</dt>
        <dd><input type="checkbox" name="IsFocus" /></dd>
        
        <dt>推荐产品：</dt>
        <dd><input type="checkbox" name="IsRecommended" /></dd>
        
        <dt>&nbsp;</dt>
        <dd>
            <button>确定</button>
            <button class="cancel" onclick="return false;">取消</button>
        </dd>
    </dl>
    </form>
</fieldset>

<script type="text/javascript">
(function($){
    
    var frm = $("#frmAddProduct");
    var uploading = frm.find(".uploading");
    var preview = frm.find(".preview");
    var filepath = frm.find("input[name=FilePath]");
    var module = "<%=this.Module %>";
    
    jqAjaxUpload("#ajaxFile","#ajaxButton",module
        ,function(){
            uploading.show();
        },function(resp){
            uploading.hide();
            if( resp ){
                filepath.val(resp);
                preview.show().attr("src", "<%=WebConf.ImagesRootPath %>/" + module + "/" + resp);
            }
    });

})(jQuery);
    
</script>